Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move user creation to a separate service #35972

Merged
merged 1 commit into from
Aug 9, 2019

Conversation

sharidas
Copy link
Contributor

@sharidas sharidas commented Aug 2, 2019

Move user creation to a separate service.

Signed-off-by: Sujith H [email protected]

Description

Move the user creation to the service class.

Related Issue

  • Fixes <issue_link>

Motivation and Context

Add the create user to a service class. It is moved from user_management apps UsersController. This will help us in integrating the change with the user:add command support creating users with username and email address. It will also help for provisioning API.

How Has This Been Tested?

  • Verified that from webUI users can be created using users page, with and without email address
  • Verified that from webUI users can be created using users page and while creation the user could be added to the group. Tested with and without email address.
  • Verified in the settings page of the logged in user and in the users page of admin that the group associated with the user is reflected.
  • Verified that using user:add command the users are created with email address and/or with password. For example:
sujith@sujith-ownCloud  ~/test/owncloud   move-createuser-toservice-v2 ●  ./occ user:add --display-name "Test User5" --email "***********" --group "group1" --group "group2" user5
Cannot load Xdebug - it was already loaded
The user "user5" was created successfully
Display name set to "Test User5"
Email address set to "************"
User user5 added to group group1
User user5 added to group group2
 sujith@sujith-ownCloud  ~/test/owncloud   move-createuser-toservice-v2 ●  
  • In the above example group1 and group2 were created and the user5 is added to the group
  • An email is sent to to the user to set the password, if the email is configured in the sever.
  • Verified that user can set the pasword.
  • Verified using provisioningapi the users are created with and without email address, for example:
sujith@sujith-ownCloud  ~/test/owncloud   move-createuser-toservice-v2 ●  curl -X POST http://admin:admin@localhost/testing/ocs/v1.php/cloud/users -d userid="test6" -d email='********' -d groups\[\]="group1" -d groups\[\]="group2"                           
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>100</statuscode>
  <message/>
 </meta>
 <data/>
</ocs>
 sujith@sujith-ownCloud  ~/test/owncloud   move-createuser-toservice-v2 ● 
  • From the above example verified that password could be reset from the email received.
  • Another example using password:
 sujith@sujith-ownCloud  ~/test/owncloud   move-createuser-toservice-v2 ●  curl -X POST http://admin:admin@localhost/testing/ocs/v1.php/cloud/users -d userid="test7" -d password="1" -d email='*********' -d groups\[\]="group2" -d groups\[\]="group1"
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>100</statuscode>
  <message/>
 </meta>
 <data/>
</ocs>
 sujith@sujith-ownCloud  ~/test/owncloud   move-createuser-toservice-v2 ● 
  • Was able to login as test7 user with the password provided in the above example. Also verified that email address is added to the user.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)

@sharidas sharidas self-assigned this Aug 2, 2019
@sharidas sharidas added this to the development milestone Aug 2, 2019
@sharidas sharidas requested a review from jvillafanez August 2, 2019 05:31
@sharidas sharidas force-pushed the move-createuser-toservice-v2 branch from 6c2cfbb to 70f2c3e Compare August 2, 2019 05:39
@codecov
Copy link

codecov bot commented Aug 2, 2019

Codecov Report

Merging #35972 into master will decrease coverage by 18.12%.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #35972       +/-   ##
=============================================
- Coverage     65.12%      47%   -18.13%     
=============================================
  Files          1299      113     -1186     
  Lines         76762    11124    -65638     
  Branches       1301     1301               
=============================================
- Hits          49995     5229    -44766     
+ Misses        26382     5510    -20872     
  Partials        385      385
Flag Coverage Δ Complexity Δ
#javascript 53.85% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 33.52% <ø> (-32.81%) 0 <ø> (-20197)
Impacted Files Coverage Δ Complexity Δ
lib/private/Files/Storage/DAV.php 58.71% <0%> (-21.37%) 0% <0%> (ø)
apps/updatenotification/templates/admin.php
lib/private/Encryption/Keys/Storage.php
lib/private/App/CodeChecker/NodeVisitor.php
lib/private/RedisFactory.php
apps/dav/lib/Avatars/AvatarNode.php
...s/dav/appinfo/Migrations/Version20170202213905.php
apps/dav/lib/Upload/ChunkLocationProvider.php
apps/files/lib/AppInfo/Application.php
apps/systemtags/list.php
... and 1171 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c570322...70f2c3e. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 2, 2019

Codecov Report

Merging #35972 into master will decrease coverage by 0.66%.
The diff coverage is 79.35%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #35972      +/-   ##
============================================
- Coverage     66.43%   65.76%   -0.67%     
- Complexity    20183    20431     +248     
============================================
  Files          1233     1308      +75     
  Lines         68965    77181    +8216     
  Branches          0     1301    +1301     
============================================
+ Hits          45814    50755    +4941     
- Misses        23151    26041    +2890     
- Partials          0      385     +385
Flag Coverage Δ Complexity Δ
#javascript 53.85% <ø> (?) 0 <ø> (?)
#phpunit 67.01% <79.35%> (+0.58%) 20431 <54> (+248) ⬆️
Impacted Files Coverage Δ Complexity Δ
core/routes.php 55.88% <ø> (ø) 0 <0> (ø) ⬇️
core/templates/new_user/resendtokenbymail.php 0% <0%> (ø) 0 <0> (?)
core/Application.php 38.05% <0%> (-1.18%) 25 <0> (ø)
core/templates/new_user/setpassword.php 0% <0%> (ø) 0 <0> (?)
core/templates/new_user/tokensendnotify.php 0% <0%> (ø) 0 <0> (?)
core/register_command.php 0% <0%> (ø) 0 <0> (ø) ⬇️
...blic/User/Exceptions/InvalidUserTokenException.php 100% <100%> (ø) 1 <1> (?)
...lic/User/Exceptions/UserTokenMismatchException.php 100% <100%> (ø) 1 <1> (?)
core/templates/new_user/email-html.php 100% <100%> (ø) 0 <0> (?)
...blic/User/Exceptions/UserTokenExpiredException.php 100% <100%> (ø) 1 <1> (?)
... and 105 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 851bd2e...30f0a5e. Read the comment docs.

@sharidas sharidas force-pushed the move-createuser-toservice-v2 branch from 70f2c3e to 04489b8 Compare August 2, 2019 11:15
Move user creation to a separate service.

Signed-off-by: Sujith H <[email protected]>
@sharidas sharidas force-pushed the move-createuser-toservice-v2 branch from 04489b8 to 30f0a5e Compare August 5, 2019 16:36
@settermjd
Copy link
Contributor

I'm not able to create a user from the WebUI without an email address, as the image below shows. I'm using ownCloud 10.3.0 prealpha.

cannot create user without email address

@sharidas
Copy link
Contributor Author

sharidas commented Aug 14, 2019

@settermjd In the users page we have a settings in the left bottom of the page. Where you have to select Set password for new users if you have to create user without email address:
users

@settermjd
Copy link
Contributor

Thanks. I'll include that in the documentation.

@sharidas
Copy link
Contributor Author

Created PR #36122 to revert this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants